// --------------------------------------------------------------------------------------------------------------------- 
// <copyright file="TransitionRule.cs" company="Scrum for Team System">
//   None
// </copyright>
// <summary>
//   Defines the TransitionRule type
// </summary>
// ---------------------------------------------------------------------------------------------------------------------

namespace ScrumForTeamSystem.EventService.TransitionService.DataStructures
{
    using System.Collections.ObjectModel;
    using System.Xml.Serialization;

    /// <summary>
    /// Defines the TransitionRule type
    /// </summary>
    public class TransitionRule
    {
        /// <summary>
        /// The eligibale target staetes.
        /// </summary>
        private readonly Collection<string> eligibleTargetStates = new Collection<string>();

        /// <summary>
        /// The sibling conditions collection.
        /// </summary>
        private readonly Collection<SiblingCondition> siblingConditions = new Collection<SiblingCondition>();

        /// <summary>
        /// The replacement collection.
        /// </summary>
        private readonly Collection<Replacement> replacements = new Collection<Replacement>();

        /// <summary>
        /// Gets the target EligibleTargetStates.
        /// </summary>
        /// <value>
        /// The eligable states.
        /// </value>
        [XmlArray]
        [XmlArrayItem(ElementName = "State")]
        public Collection<string> EligibleTargetStates
        {
            get
            {
                return this.eligibleTargetStates;
            }
        }

        /// <summary>
        /// Gets the replacements.
        /// </summary>
        /// <value>The replacements.</value>
        [XmlArray]
        [XmlArrayItem(ElementName = "Replacement")]
        public Collection<Replacement> Replacements
        {
            get
            {
                return this.replacements;
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether this instance is excluded from synchronisation.
        /// </summary>
        /// <value>
        /// <c>true</c> if this instance is excluded from synchronisation; otherwise, <c>false</c>.
        /// </value>
        [XmlAttribute(AttributeName = "syncexcluded")]
        public bool IsExcludedFromSynchronisation
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets Transition.
        /// </summary>
        /// <value>
        /// The transition.
        /// </value>
        public Transition Transition
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the type of the link.
        /// </summary>
        /// <value>The type of the link.</value>
        public LinkType LinkType
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the names of the work item types.
        /// </summary>
        /// <value>The names of the work item types.</value>
        public SourceTargetPair WorkItemTypeName
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the reason.
        /// </summary>
        /// <value>The reason.</value>
        public string ChangeNote
        {
            get;
            set;
        }

        /// <summary>
        /// Gets the sibling rules.
        /// </summary>
        /// <value>The sibling rules.</value>
        [XmlArray]
        [XmlArrayItem(ElementName = "SiblingCondition")]
        public Collection<SiblingCondition> SiblingConditions
        {
            get
            {
                return this.siblingConditions;
            }
        }

        /// <summary>
        /// Gets or sets the description.
        /// </summary>
        /// <value>The description.</value>
        [XmlIgnore]
        public string Description
        {
            get;
            set;
        }
    }
}